#include<iostream>
#include<unistd.h>
#include<signal.h>
using namespace std;
void handler(int sig){
    cout << "my id:" << getpid() <<" I receive SIGCHLD:"<<sig <<  endl; 
}
int main(){
    signal(SIGCHLD,handler);
    pid_t id = fork();
    if(id == 0){   //child
        cout << "my child:" << getpid() << "my parent" << getppid() << endl;
        sleep(5);
        exit(1);
    }
    cout << "my parent:" << getpid() << endl;
    
    sleep(10);
    return 0;
}